/*
 * @Author: 天稻 2283341909@qq.com
 * @Date: 2023-02-15 23:59:24
 * @LastEditors: 天稻 2283341909@qq.com
 * @LastEditTime: 2023-04-19 17:17:32
 * @FilePath: \node-project\models\music_db\user_manage.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
const mongoose = require('mongoose')
const {generateId} = require('../../utils/index')
const { dbHost } = require('../../conf/index')
mongoose.connect(`mongodb://${dbHost}/music_db`)

const Schema = mongoose.Schema

const shangpinSchema = new Schema({
  userPhone: { type: String }, //电话
  userNo: {
    type: String,
    default() {
      return generateId('YH')
    }
  },
  nickname: {
    type: String,
    default() {
      return crypto.randomUUID()
    }
  }, //昵称
  account: { type: String, required: [true, '账号为空'] }, //账号
  password: { type: String, required: [true, '密码为空'] }, //密码，真实密码
  sex: { type: Number, default: 1 }, //1代表男，0代表女
  img_url: { type: String, default: '/public/svg/man_img.svg' }, // 默认头像
  birthDay: { type: String, default: new Date() },
  signature: { type: String, default: '天上天下，唯我独尊' }, // 个性签名
  city: { type: Array, default: ['110000', '110100', '110101'] }, // 地区
  collectSong:{type: Array,default:[]}
})

module.exports = mongoose.model('user_manage', shangpinSchema)
// first.save().then(
//   data => console.log(data),
//   err => console.log('shibai')
// )
// Shopuser.find({$or:[{goods_price:{$lt:200}}]},{id:true,_id:false}).limit(10)
//     .then((data) => console.log(data),
//         (err) => console.log('shibai'))
// Shopuser.find().then(
//   data => console.log(data),
//   err => console.log('shibai')
// )
// Shopuser.updateOne({ phone: '19189508256' }, { person_id: '123456789' }).then(
//   value => console.log('chenggong', value),
//   reason => console.log('shibai')
// )
// Shopuser.deleteMany().then(
//   data => console.log('chenggong'),
//   err => console.log('shibai')
// )
